package com.ftg.learn.chapter02.javabase;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * 接口类，映射类
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/12/26 上午8:51
 */
public interface Isysuser {

    // 查询所有张姓同学

    // 查询所有张姓同学  密码长度为 6

    //动态sql
    // 查询所有张姓同学  密码长度为 6  可以都填，可能都不填，或者添加某一个


    @Select("select * from sys_user")
    List<Map<String,Object>> queryAll();

//    @Select("select * from sys_user where username like concat(#{username},'%') and char_length(password) = 6 ")
    @Select("select * from sys_user where username like concat(#{username},'%') and password like '______' ")
    List<Map<String,Object>> queryAllWithParameter(@Param("username") String username);


    List<Map<String,Object>> queryAllWithParameter2(@Param("username") String username,@Param("len") Integer len);


    int insert(User user);

    @Update("update sys_user set username = #{username},password=#{password} where id=#{id}")
    int modify(User user);

    @Update("update sys_user set username = #{user.username},password=#{user.password} where id=#{newid}")
    int modify1(@Param("user") User user,@Param("newid") int newid);

    @Delete("delete from sys_user where id = #{id}")
    int deleteById(@Param("id") int id);


    int modifyUser(User user);


    int deleteUserById(@Param("id") Integer id);


}
